package com.jdk.mode.struct;

/**
 * @author jukg
 * @date 2023/08/25 16:41
 * @description 装饰器模式
 */
public class Decorator {

    public static void main(String[] args) {

    }
}

interface Pizza{
    String getName();
    Integer getPrice();
}

class RealPizza implements Pizza{
    String name;
    Integer price;

    public RealPizza(String name, Integer price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public Integer getPrice() {
        return this.price;
    }
}

abstract class PizzaDecorator implements Pizza{

    protected Pizza pizza;

    public PizzaDecorator(Pizza pizza) {
        this.pizza = pizza;
    }

    public String getName(){
        return this.pizza.getName();
    }

    public Integer getPrice(){
        return this.pizza.getPrice();
    }
}


class Decorator1 extends PizzaDecorator{

    public Decorator1(Pizza pizza) {
        super(pizza);
    }

}

class Decorator2 extends PizzaDecorator{

    public Decorator2(Pizza pizza) {
        super(pizza);
    }

}
